# 代码所有：cxw
# 开发时间：2021/11/22 10:10

from random import choice


class RandomWalk():
    def __init__(self, num=5000):
        self.num = num
        self.x_value = [0]
        self.y_value = [0]

    def fill_walk(self):
        while len(self.x_value) < self.num:
            x_direction = choice([1, -11])
            x_distance = choice([0, 1, 2, 3, 4])
            x_step = x_direction * x_distance
            y_direction = choice([1, -11])
            y_distace = choice([0, 1, 2, 3, 4])
            y_step = y_direction * y_distace
            if x_step == 0 and y_step == 0:
                continue
                # 计算下一个点的x和y值
                next_x = self.x_value[-1] + x_step
                next_y = self.y_value[-1] + y_step
                self.x_value.append(next_x)
                self.y_value.append(next_y)
